package ctrlayer;
import modellayer.*;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class VareCtrTest.
 *
 * @author  Søren Kaae
 * @version 04.12.2014
 */
public class VareCtrTest
{
    private static int counter = 0;
    /**
     * Default constructor for test class VareCtrTest
     */
    public VareCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void CreateVare()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        assertEquals(true, vareCtr1.createVare("Hammer", "Det er en hammer", 25.95, 1, 10, 5, 15));
        counter++;
    }

    @Test
    public void sletVare()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        vareCtr1.createVare("Hammer", "Det er en hammer", 25.95, 2, 10, 5, 15);
        counter++;
        assertEquals(true, vareCtr1.deleteVare(counter));
        //counter;
    }

    @Test
    public void sletVareDerIkkeErDer()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        assertEquals(false, vareCtr1.deleteVare(Integer.MAX_VALUE));
    }

    @Test
    public void redigerVare()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        vareCtr1.createVare("Hammer", "Det er en hammer", 25.95, 3, 10, 5, 15);
        counter++;
        assertEquals(true, vareCtr1.updateVare(counter, "Hammer", "Det er stadig en hammer", 123, 5, 20));
    }

    @Test
    public void redigerVareDerIkkeErOprettet()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        assertEquals(false, vareCtr1.updateVare(Integer.MAX_VALUE, "Hammer", "Det er stadig en hammer", 1234, 10, 20));
    }

    @Test
    public void retPris()
    {
        ctrlayer.VareCtr vareCtr1 = new ctrlayer.VareCtr();
        ctrlayer.PersonCtr personCtr1 = new ctrlayer.PersonCtr();
        vareCtr1.createVare("Hammer", "Det er en hammer", 25.95, 12345, 10, 5, 15);
        counter++;
        assertEquals(true, vareCtr1.retPris("0" , counter, 24.95));
    }
}

